package lizi;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Scanner;

public class StudentTest {
    public static void main(String[] args) {
        ArrayList<Student> arr = new ArrayList();
        Scanner sc = new Scanner(System.in);
        System.out.println("存储几个学生");
        int a = sc.nextInt();

        int i;
        for(i = 0; i < a; ++i) {
            System.out.println("请输入学生名字");
            Student student = new Student();
            student.setName(sc.next());
            System.out.println("请输入年纪");
            student.setId(sc.next());
            arr.add(student);
        }

        for(i = 0; i < arr.size(); ++i) {
            PrintStream var10000 = System.out;
            String var10001 = ((Student)arr.get(i)).getName();
            var10000.println(var10001 + ((Student)arr.get(i)).getId());
        }

        while(true) {
            System.out.println("请输入1-3");
            System.out.println("1查看");
            System.out.println("2修改");
            System.out.println("3删除");
            switch (sc.next()) {
                case "1":
                    chakan(arr);
                    break;
                case "2":
                    xiugai(arr);
                    break;
                case "3":
                    sahnchu(arr);
            }
        }
    }

    public static void chakan(ArrayList<Student> arr) {
        for(int i = 0; i < arr.size(); ++i) {
            PrintStream var10000 = System.out;
            String var10001 = ((Student)arr.get(i)).getName();
            var10000.println(var10001 + ((Student)arr.get(i)).getId());
        }

    }

    public static void xiugai(ArrayList<Student> arr) {
        Scanner sc = new Scanner(System.in);

        for(int i = 0; i < arr.size(); ++i) {
            System.out.println("请输入你要修改的学生名");
            String snm = sc.next();
            if (((Student)arr.get(i)).getName().equals(snm)) {
                System.out.println("请输入修改后的名字");
                String nam = sc.next();
                ((Student)arr.get(i)).setName(nam);
                break;
            }

            System.out.println("没找到");
        }

    }

    public static void sahnchu(ArrayList<Student> arr) {
        Scanner sc = new Scanner(System.in);

        for(int i = 0; i < arr.size(); ++i) {
            System.out.println("请输入要删除的学生名");
            String nm = sc.next();
            if (((Student)arr.get(i)).getName().equals(nm)) {
                arr.remove(i);
                break;
            }

            System.out.println("没找到");
        }

    }
    }

